import { defineStore } from "pinia";

export const userStore = defineStore("user", {
  state: () => ({
    userInfo: {}, // 初始化为空对象
    pythons: []
  }),
  actions: {
    // 设置用户信息
    setUserInfo(userInfo) {
      this.userInfo = userInfo;
    },
    // 清空用户信息
    clearUserInfo() {
      this.userInfo = {};
    },
  },
  persist: {
    enabled: true,
    strategies: [
      {
        storage: localStorage,
        paths: ["userInfo"], // 只持久化 userInfo
      },
    ],
  },
});